package com.fs.common.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author liji
 * 获取线程池的单例实例
 */
public class ThreadPoolUtils {

    private ThreadPoolUtils(){}

    public static ExecutorService getThreadPool(){
        return SingletonThreadPool.PoolInstance;
    }

    public static void execute(Runnable command){
        getThreadPool().execute(command);
    }

    private static class SingletonThreadPool {
        /**
         * 静态初始化器，由JVM来保证线程安全
         */
        private static ExecutorService PoolInstance = Executors.newCachedThreadPool();
    }
}
